package com.darren.framework.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * @author: qinzx
 * @date: 2018/5/30 14:03
 * @modify by:
 */
//@Component
@Configuration
@EnableSwagger2
//@EnableWebMvc
//@ComponentScan("com.darren.*.action")
public class Swagger2Config extends WebMvcConfigurationSupport {

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .license("Apache License Version 2.0")
                .title("Swagger2 集成测试")
                .description("Swagger2 API")
                .termsOfServiceUrl("http://www.daodaodao.club")
                .version("1.0")
                .build();
    }

    @Bean
    public Docket createRestApi() {
        System.out.println("Swagger2Config.createRestApi");
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.darren"))
                .paths(PathSelectors.any())
                .build();
    }


}